import { asyncRouterMap,constantRouterMap } from '@/router';

function hasPermission(rightlist, route) {
  if (route.meta && route.meta.right) {
    return rightlist.indexOf(route.meta.right)>=0
  } else {
    return true
  }
}

function filterAsyncRouter(asyncRouterMap, rightlist) {
  const accessedRouters = asyncRouterMap.filter(route => {
    if (hasPermission(rightlist, route)) {
      if (route.children && route.children.length) {
        route.children = filterAsyncRouter(route.children, rightlist)
      }
      return true
    }
    return false
  })
  return accessedRouters
}

const permission = {
  state: {
    routers: constantRouterMap,
    addRouters: [],
  },
  mutations: {
    
  },
  actions: {
    
  },
  computed: {
    routes: function () {
       
    }
  },

}
export default permission